package test.batch;

import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import streaming.api.beans.SensorReading;

import java.util.Arrays;
import java.util.List;

public class WordCount2 {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        ParameterTool parameterTool = ParameterTool.fromArgs(args);
        String test = parameterTool.get("test");
        System.out.println(test);
        //从集合中读取数据
        List<SensorReading> dataArr = Arrays.asList(
                new SensorReading("sensor_1", 10000L, 10.8),
                new SensorReading("sensor_2", 148763L, 65.3),
                new SensorReading("sensor_3", 36254L, 23.65),
                new SensorReading("sensor_4", 83627L, 9.34),
                new SensorReading("sensor_5", 232261L, 36.34)
        );
        // 转 数据流
        DataStream<SensorReading> dataStream = env.fromCollection(dataArr);
        //打印输出
        dataStream.print("data:");
        //执行
        env.execute();
    }
}
